<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/js/jquery-easyui-1.4.3/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/js/jquery-easyui-1.4.3/themes/icon.css">
	<link rel="stylesheet" href="__PUBLIC__/css/base.css">
	<script type="text/javascript" src="__PUBLIC__/js/jquery-1.7.2.min.js"></script>
	<script type="text/javascript" src="__PUBLIC__/js/jquery-easyui-1.4.3/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="__PUBLIC__/js/outlook2.js"></script>
	
	<script type="text/javascript" src="__PUBLIC__/js/dp/WdatePicker.js"></script>
	<script>
	$(function(){
		$('#dg').datagrid({
			columns:[[
				{field:'id',title:'id',hidden:'hidden'},
				{field:'orderid',title:'订单号'},
				{field:'fcallbackurl',title:'充值回调地址'},
				{field:'status',title:'回调通知状态',
					formatter:function(value,row,index){
							var tt= "";
							if(value == 0){
								tt = "未通知";
							}else if(value == 1){
								tt = "已通知";
							}else if(value == 2){
								tt = "通知失败";
							}else if(value == 3){
								tt = "更新数据失败";
							}
							return tt; 
						 }
				},
				{field:'payflag',title:'充值状态',
					formatter:function(value,row,index){
							var tt= "";
							if(value == 0){
								tt = "待支付";
							}else if(value == 1){
								tt = "支付成功";
							}else if(value == 2){
								tt = "支付失败";
							}
							return tt; 
						 }
				},
				
				{field:'create_time',title:'下单时间',
					formatter:function(value,row,index){
						if(value != null){
							var tt=new Date(parseInt(value) * 1000).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");
							return tt; 
						}
					 }
				},
				{field:'update_time',title:'最后通知时间',
					formatter:function(value,row,index){
						if(value != null){
							var tt=new Date(parseInt(value) * 1000).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");
							return tt; 
						}
					 }
				},
				{field: 'sid', title: '操作', 
						formatter: function (value, row, index) {
						var d = value;
					   if(value !=null ){
						var d = "<a class='l-btn l-btn-plain' onclick=\"additional("+index+",'{:U('Pay/additional')}')\"><span class='l-btn-left'><span class='l-btn-text icon-note-edit l-btn-icon-left'>补单</span></span></a>"
						
						}
					return d;
					}
				},
			]],
		});
	});

	//查询
	function doSearch(){
		$('#dg').datagrid('load',{
			start: $('#start').val(),
			end: $('#end').val(),
			orderid: $('#orderid').val()
		});
	}	

	//打包
	function additional(index,urls){  
		$.messager.confirm('Confirm','确认要为执行该操作吗?',function(r){  
			if (r){               
			var Row = $('#dg').datagrid('getSelected');  //获取选中行  
			
			if(Row){
				$.ajax({  
					url : urls,  
					type : 'POST',
					data:{id:Row.id,orderid:Row.orderid},
					success : function(data) {
						var result = eval('('+data+')');
						if (result.success){
							$('#dg').datagrid('reload');	// reload the user data
							$.messager.show({
								title: 'success',
								msg: result.msg
							});
						} else {
							$.messager.show({
								title: 'Error',
								msg: result.msg
							});
						}
					}  
				},'json'); 
			}
			  
			}  
		});  
	}
</script>
</head>
<body>
<div style="margin:5px 0;"></div>
		<div  title="DataGrid">
			<table id="dg" class="easyui-datagrid" style="height:472px" url="{:U('pay/additionalList')}" toolbar="#toolbar" title="Load Data" pagination="true" singleSelect="true">
			</table>
			<div id="toolbar" style="padding:5px;height:auto">
				
				<table>
					<tr>
					<td>开始时间:</td>
					<td><input id="start" class="easyui-my97" name="start" 
					data-options="disabled:false,startDate:'%y-%M-%d 00:00:00'" datefmt="yyyy-MM-dd 00:00:00"  style="width:135px" onClick="new WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});"></td>
				
					<td>结束时间:</td> <td><input id="end" class="easyui-my97" name="end" 
					data-options="disabled:false,startDate:'%y-%M-%d 23:59:59'" datefmt="yyyy-MM-dd 23:59:59" style="width:135px" onClick="new WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});"></td>
					
					<td>订单号:</td> <td><input id="orderid" class="easyui-textbox" type="text" name="orderid"  style="width:135px"></td>
					</tr>
					<tr>
					<td><a href="#" class="easyui-linkbutton" iconCls="icon-search" onClick="doSearch()">查询</a></td>
					</tr>
				</div>
			</div>
			
</div>
</body>
</html>